#pragma once

#include "Vector2D.h"
#include "Point.h"
#include <map>
#include <string>
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
#include "Sprite.h"
#include "Map.h"

using namespace std;

// bouding square

struct cSquare
{
	int x_center;
	int y_center;
	int radius;
};

class GameObject
{
public:

	GameObject()
	{
		m_position.x = 0;
		m_position.y = 0;
	}
	virtual ~GameObject();

	// init for object
	void add(Sprite &_sprite, int &_idSprite, SDL_Renderer* _pRenderer, Map* _map);
	virtual void load(int x, int y, int width, int height, int _radius, std::string textureID);

	virtual void update(Point &possition);
	virtual void draw();
	virtual void clean();

	//GETs
	virtual Point& getPosition();
	virtual Vector2D& setVelocity(const Vector2D& _velocity);
	virtual Vector2D& setAccelertion(const Vector2D& _accelertion);
	virtual void SetPosition(float x, float y) { m_position.x = x; m_position.y = y; }

	virtual float getX() { return m_position.x; }
	virtual float getY() { return m_position.y; }

	virtual void setIsExpired(const int &status);

	SDL_Rect GetBoundingBoxObject(std::string id);

	int getWidth() const;
	int getHeight() const;
	float getRadius() const;

	Vector2D getVelocity() const
	{
		return m_velocity;
	}

	bool isExpired() ;

	void setSpeed(const float &speed);

	SDL_Rect getBox() const;
	cSquare getSquare() const;
	//std::vector<SDL_Rect> &get_rect() const;

	int CheckLeft(int &_x, int &_y);
	int CheckRight(int &_x, int &_y);
	int CheckUp(int &_x, int &_y);
	int CheckDown(int &_x, int &_y);
	
protected:
	// bouding box
	SDL_Rect box;
	// bouding square
	cSquare square;
	// pixel based
	//vector<SDL_Rect> boxPixel;

	// Sprite

	Sprite m_sprite;
	int m_idSprite;
	SDL_Renderer* m_pRenderer;
	Map* m_map;
	///////////////////////////////////

	Point	 m_position; //controls position of the GameObject
	Vector2D m_velocity; //controls velocity of the GameObject
	Vector2D m_acceleration; //controls acceleration of the GameObject ???

	// image
	string m_textureID;
	int m_width;
	int m_height;

	//
	float	 m_speed;

	//time
	unsigned int m_lastTime, m_currentTime;
	Uint32 frameStart, frameTime;
	///////////////////////////

	float timeOfGame;
	float dt;
	float timeDelay;

	float m_radius;
	bool m_IsExpired;

	bool mAnimation;
	int id_magic_sprite;
private:
};